<?php

namespace app\admin\controller;

use app\admin\model\FitUser;
use think\console\command\make\Model;
use \think\Db;
use \think\Cookie;
use \think\Session;
use app\admin\model\Admin as adminModel;//管理员模型
use app\admin\model\AdminMenu;
use app\admin\controller\Permissions;

class User extends Permissions
{

    /**
     * 用户列表信息
     * Date: 2019/08/10
     */
    public function user()
    {
        $user = new FitUser();
        if (request()->isPost()) {
            $name = input('keywords');
            if ($name == '') {
                $info = $user->where('is_delete',0)->order('fit_id desc')->paginate(10);
            } else {
                $info = $user->where('fit_name', $name)->where('is_delete',0)->paginate(10);
            }
        } else {
            $info = $user->getFitUser();
        }

        $page = $info->render();
        $this->assign('page', $page);
        $this->assign('info', $info);
        return $this->fetch();
    }

    /**
     * 删除用户信息
     * Date: 2018/11/21
     */
    public function user_delete()
    {
        $id = input('id');
        $user = new FitUser();
        // $user = $user->where('fit_id', $id)->delete();
        $user = $user->where('fit_id', $id)->update(['is_delete'=>1]);
        if ($user >= 0) {
            $this->success('删除成功', 'user/user');
        } else {
            $this->error('数据出错', 'user/user');
        }
    }

}
